const server = require("../../server/server.js");
Page({
    data:{
        products:[],
        params:{
            page:1,
            rows:4,
            title:"",
            mode:""
        },
    },
    reload({ currentTarget: { dataset: { mode } } }) {
        console.log(mode)
        this.setData({
            "params.mode":mode,
            products:[]
        });
        this.loadProductList();
    },
    onLoad(options){
        this.setData({
            "params.title":options.wk,
        });
        this.loadProductList(options.wk);
    },
    loadProductList(){
        return server.loadProductList(this.data.params)
            .then((data)=>{
                console.log(data)
                this.setData({
                    products:this.data.products.concat(data.rows),
                    total:data.total
                })
            })
            .catch((error)=>{
                console.log(error);
            })
    }
})